package com.example.administrator.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

public class TowActivity extends AppCompatActivity {

    private LinearLayout linearLayout;
    private Button button;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tow);
        //先后循序
        initView();
        intiData();
        initEvent();
    }
    //第一步 创建视图
    private void initView(){
        linearLayout = (LinearLayout) findViewById(R.id.linearlayout);
        button = (Button) findViewById(R.id.button);
    }
    //第二步 获取数据
    private void intiData(){
        //ctrl+alt+f
    }
    //第三步 事件监听
    private void initEvent(){
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                linearLayout.setBackgroundColor(getResources().getColor(R.color.colorAccent));
            }
        });
    }
}
